package com.zoe.springcloud.web;/*
 *@date 2019/12/11 0011
 */

import com.alibaba.fastjson.JSONObject;
import com.zoe.springcloud.service.RibbonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xjr
 */
@RestController
@RequestMapping("/ribbon-consumer")
public class ConsumerController {

    @Value("${server.port}")
    private String port;
    private final  RibbonService ribbonService;

    public ConsumerController(RibbonService ribbonService) {
        this.ribbonService = ribbonService;
    }


    @GetMapping("/send")
    public Object send(String message){

        return JSONObject.parseObject(ribbonService.send(message));
    }

    @GetMapping("/zuulSend")
    public Object zuulSend(String message){
        JSONObject object= JSONObject.parseObject(ribbonService.send(message));
        object.put("ribbon-port",port);
        return object;
    }
}
